package com.example.tys.baseapplication.NetModel.executor;

import com.example.tys.baseapplication.NetModel.network.ClientException;

import java.io.IOException;

/**
 *
 * @author tys
 * @date 2019/2/12
 */

public interface Action<R> {

    /**
     * 子线程中执行
     *
     * @return
     * @throws ClientException
     * @throws IOException
     */
    R doTask() throws ClientException, IOException;

    /**
     * 主线程中执行
     *
     * @param response {@link #doTask()}返回结果
     */
    void onSuccess(R response);

    /**
     * 主线程中执行
     * {@link #doTask()} 执行失败
     */
    void onFailed(Throwable e);
}
